﻿<!doctype html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <title>减免金额</title>
    <link href="/admin_wechat/css/css.css" rel="stylesheet" />
    <script src="/admin_wechat/scripts/common/jquery.js"></script>
    <script src="/admin_wechat/scripts/common/ajax-data.js"></script>
    <script src="/admin_wechat/scripts/common/base.js"></script>
    <script src="/admin_wechat/scripts/common/dialog.js"></script>
    <script src="/admin_wechat/scripts/order.js"></script>
    <style type="text/css">
    .order {text-align: center;width: 95%;height: 45px;margin-left: auto;margin-right: auto;margin-top: 20px;border: 1px solid #ddd;line-height: 45px;}
    .order input {height: 35px;width: 90%;border-style: none;outline: none;font-size: 18px;}
    .submit {width: 95%;height: 40px;border-radius: 20px;line-height: 40px;background-color: #f37b0b;color: #fff;text-align: center;margin: 50px auto 0px auto;font-size: 18px;}
    .zonge{width: 50%;height: 45px;line-height: 45px;}
    .zhifu{width: 50%;height: 45px;line-height: 45px;}
    .zhifu_box{
        height: 45px;
        width: 95%;
        margin-left: auto;
        margin-right: auto;
        margin-top: 20px;
        display:flex;
        justify-content:flex-start;
        align-items:center;
        border: 1px solid #ddd;
        font-size: 18px;
        color:#757575;
    }
     </style>
</head>
<body>
    <div>
        <div class="zhifu_box"><span style="margin-left:5%;">商品总额 : </span><div class="zonge SurplusMoney red"></div></div>
        <div class="order">
            <input type="number" id="discount" placeholder="输入减免金额" onblur="zheKou()"/>
        </div>
        <div class="zhifu_box"><span style="margin-left:5%;">需支付金额 ：</span><div class="zhifu"></div></div>
        <!--<div style="color:#aaa; text-align:left;margin-left:10%;margin-top:10px;">如需要减免1.98元，则输入数字1.98</div>-->
        <div class="submit">确&nbsp;&nbsp;认&nbsp;&nbsp;提&nbsp;&nbsp;交</div>
    </div>
    <script>
        $(function () {
            var uid = getQueryString("uid")
            var oid = getQueryString("oid")
            var osn = getQueryString("osn")
            if (osn != '')
                loadDetailByOSN(uid, osn);
            else
                loadDetail(uid, oid);
            $(".submit").click(function () {
                var discount = $("#discount").val();
                update_discount(oid, uid, discount)
            });
            var zhifu = $(".zonge").html()
            console.log(zhifu)
            $(".zhifu").html(zhifu)
        });
        function zheKou() {
            var zongjia = parseInt($(".SurplusMoney").html().substr(1))
            var discount = $("#discount").val()
            if (discount <= zongjia && discount>=0) {
                var zhifu = zongjia - discount
                zhifu = 
                $(".zhifu").html("¥"+zhifu)
            }
            else if (discount < 0) {
                $(".zhifu").html("¥" + zongjia)
            }
            else
                $(".zhifu").html("¥" + 0)
        }
    </script>
</body>
</html>
